package spzx.controller;

import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import spzx.service.FileUploadService;

@RestController
@RequestMapping("admin/avatar")
public class FileUploadController {

    @Autowired
    FileUploadService fileUploadService;

    /**
     * 上传图片文件用接口
     * @param multipartFile
     * @return url
     */
    @PostMapping("/upload")
    public Result upload(MultipartFile multipartFile) {
        String url = fileUploadService.upload(multipartFile);
        return Result.build(url, ResultCodeEnum.SUCCESS);
    }
}
